package com.maila.xiaoaobusiness.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;

import com.dinuscxj.refresh.RecyclerRefreshLayout;
import com.maila.xiaoaobusiness.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by mark on 2017/11/20.
 */

public class OrderFragment extends Fragment {
    @BindView(R.id.rb_new)
    RadioButton rbNew;
    @BindView(R.id.rb_unfinished)
    RadioButton rbUnfinished;
    @BindView(R.id.lv_order)
    ListView lvOrder;
    @BindView(R.id.refresh_layout)
    RecyclerRefreshLayout refreshLayout;
    @BindView(R.id.iv_no_data)
    ImageView ivNoData;
    Unbinder unbinder;
    int type = 0;// 0,新订单 1,未完成

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View footview = inflater.inflate(R.layout.fragment_order, container, false);
        unbinder = ButterKnife.bind(this, footview);
        return footview;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    void setstatus() {
        rbNew.setChecked(false);
        rbUnfinished.setChecked(false);
        if(type==0){
            rbNew.setChecked(true);
            //todo  临时展示
            refreshLayout.setVisibility(View.VISIBLE);
            ivNoData.setVisibility(View.GONE);
        }else {
            rbUnfinished.setChecked(true);
            refreshLayout.setVisibility(View.GONE);
            ivNoData.setVisibility(View.VISIBLE);
        }

    }

    @OnClick({R.id.rb_new, R.id.rb_unfinished})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rb_new:
                type=0;
                setstatus();
                break;
            case R.id.rb_unfinished:
                type=1;
                setstatus();
                break;
        }
    }
}
